<template>
	<view class="item c-flex_row" @click="tapItem">
		<image class="avater" :src="unit.avatar" mode="aspectFill"></image>
		<view class="info c-flex_1 c-flex_column">
			<view class="name">
				{{unit.englishTitle}}
			</view>
			<view class="desc c-flex_1">
				{{unit.summary}}
			</view>
			<view class="chat-count">
				{{unit.vocabulary}}
			</view>
			<view class="c-flex_row c-justify_end">
				<uni-icons custom-prefix="iconfont" type="icon-e-suo" color="#999" size="20"
					v-if='showLock'></uni-icons>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			unit: {
				type: Object,
				default: function() {
					return null;
				}
			}
		},
		data: function() {
			return {}
		},
		computed: {
			showLock: function() {
				return !this.unit || !this.unit.promise
			}
		},
		methods: {
			tapItem() {
				this.$emit("tapItem", this.unit);
			}
		}
	}
</script>

<style lang="scss" scoped>
	.item {

		.avater {
			width: 240rpx;
			height: 170rpx;
			border-radius: 15rpx;
		}

		.info {
			margin-left: 20rpx;

			.name {
				color: #1893ed;
				font-size: 28rpx;
				font-weight: 700;
			}

			.desc {
				margin-top: 15rpx;
				color: #999;
				font-size: 24rpx;
				word-wrap: break-word;
				word-break: break-all;
			}

			.chat-count {
				margin-top: 15rpx;
				font-size: 26rpx;
				color: #333;
				font-weight: 700;
			}

			.chat-count::before {
				content: "单词数：";
			}
		}
	}
</style>